#include "precompiled.h"
#include "character.h"
#include "itemparser.h"
#include "optimizefull.h"
#include "enchant.h"
#include "itemdatabase.h"
#include "enhancement.h"
#include "restoration.h"
#include "holypriest.h"
#include "characterfactory.h"
#include "mainwindow.h"
using namespace weo::engine::item;
using namespace weo::engine::character;
using namespace weo::engine::optimization;
using namespace std;
void createDB()
{
	Itemdatabase * db = new Itemdatabase();
	Itemparser *ip = new Itemparser(db);
	ip->parseFiles();
	db->SaveDB("itemdb.xbz");
}
int loadChar(int argc, char* argv[])
{
	CharacterFactory::RegisterClassBuild("Shaman","Enhancement",CharacterFactory::FactoryFunction<weo::engine::character::shaman::Enhancement>);
	CharacterFactory::RegisterClassBuild("Shaman","Restoration",CharacterFactory::FactoryFunction<weo::engine::character::shaman::Restoration>);
	CharacterFactory::RegisterClassBuild("Priest","Holy",CharacterFactory::FactoryFunction<weo::engine::character::priest::Holy>);
	Itemdatabase *db = new Itemdatabase();
	std::string classname = "Priest";
	std::string buildname = "Holy";
	if(argc > 2)
	{
		classname = argv[1];
		buildname = argv[2];
	}
	Character *ch = CharacterFactory::CallFactory<Character>(classname,buildname);
	if(!ch)
	{
		cout << "Can't find class/build combination" << endl;
	}
	else
	{
		cout << "Starting optimization for: " << classname << "/" << buildname << endl;
	}
	if(!db->LoadDB("itemdb.xbz")) return -1;
	vector<vector<Item>> items;
	ch->Database(*db);
	ch->filterEquip(items);
	OptimizeFull *of = new OptimizeFull(items);
	of->Character(ch);
	of->Optimize();
	return 0;
}
int main(int argc, char* argv[])
{
//	createDB();
//	loadChar(argc, argv);
	QApplication app( argc, argv );
	// create a new instance of MainWindow
	MainWindow mainWindow;	
	mainWindow.show();

	// Enters the main event loop and waits until exit() is called 
	// or the main widget is destroyed, and Returns the value that 
	// was set via to exit() (which is 0 if exit() is called via quit()). 
	return app.exec();
}